package com.pioneer.beans;

import java.util.List;
import java.util.Iterator;
import java.util.ArrayList;

/**
 * Title:        Pioneer Metals Application
 * Description:
 * Copyright:    Copyright (c) 2001
 * Company:      Pioneer Metals
 * @author Gary Chen
 * @version 1.0
 */

public class Container {

	private String id;
	private List contentList;
	private String supplier;

    public Container(String id, String supplier) {
		this.id=id;
		this.supplier = supplier;
		contentList=new ArrayList();
    }


	public String getId() {
		return this.id;
	}
	
	public String getSupplier(){
		return this.supplier;
	}

	public void addContent(ContainerContent content)
	{
		contentList.add(content);
	}

	public boolean deleteContent(String description)
	{
		return contentList.remove(getContent(description));
	}

	public List getContents()
	{
		/*Object[] contents=contentList.toArray();
		ContainerContent[] contentArr=new ContainerContent[contents.length];
		for (int count=0;count<contents.length;count++)
		{
			contentArr[count]=(ContainerContent)contentArr[count];
		}
		return contentArr;*/
		return contentList;
	}

	protected ContainerContent getContent(String description)
	{
		ContainerContent foundContent=null;
		Iterator contents=contentList.iterator();
		while (contents.hasNext())
		{
			ContainerContent content=(ContainerContent)contents.next();
			if (content.getDescription().equals(description))
			{
				foundContent=content;
				break;
			}
		}
		return foundContent;
	}

}